package cloudy.trident.tools;

import cloudy.tools.DateFmt;
import org.apache.storm.trident.operation.BaseFunction;
import org.apache.storm.trident.operation.TridentCollector;
import org.apache.storm.trident.tuple.TridentTuple;
import org.apache.storm.tuple.Values;

/**
 * @Name cloudy.trident.tools.Print
 * @Description
 * @Author Elwyn
 * @Version 2017/9/30
 * @Copyright 上海云辰信息科技有限公司
 **/
public class OrderSplit extends BaseFunction {
	private String patten;

	public OrderSplit(String patten) {
		this.patten = patten;
	}

	@Override
	public void execute(TridentTuple tridentTuple, TridentCollector tridentCollector) {
		if (!tridentTuple.isEmpty()){
			String string = tridentTuple.getString(0);
			String value[] = string.split(patten);
		//"order_id", "order_amt", "create_time", "province_id"
			if (value.length>1){

				tridentCollector.emit(new Values(value[0],Double.valueOf(value[1]), DateFmt.getCountDate(value[2],DateFmt.date_short),value[3]));
			}

			System.err.println("sssss"+string);
		}
	}
}
